package com.lrkj.web.controller.ureport;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.ureport.domain.ReportGroup;
import com.lrkj.ureport.service.IReportGroupService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 报分组Controller
 *
 * @author yajun_ren
 * @date 2022-04-01
 */
@RestController
@RequestMapping("/reportGroup")
@Api(tags = "报分组")
public class ReportGroupController extends BaseController
{
    @Autowired
    private IReportGroupService reportGroupService;

    /**
     * 查询报分组列表
     */
    @ApiOperation(value = "查询报分组列表", notes = "查询报分组列表")
    @PreAuthorize("@ss.hasPermi('ureport:reportGroup:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReportGroup reportGroup)
    {
        startPage();
        this.changeParameter(reportGroup.getParams());
        List<ReportGroup> list = reportGroupService.selectReportGroupList(reportGroup);
        return getDataTable(list);
    }

    /**
     * 导出报分组列表
     */
	@ApiOperation(value = "导出报分组列表", notes = "导出报分组列表")
    @PreAuthorize("@ss.hasPermi('ureport:reportGroup:export')")
    @Log(title = "报分组", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ReportGroup reportGroup)
    {
        List<ReportGroup> list = reportGroupService.selectReportGroupList(reportGroup);
        ExcelUtil<ReportGroup> util = new ExcelUtil<ReportGroup>(ReportGroup.class);
        return util.exportExcel(list, "报分组数据");
    }

    /**
     * 获取报分组详细信息
     */
	@ApiOperation(value = "获取报分组详细信息", notes = "获取报分组详细信息")
    @PreAuthorize("@ss.hasPermi('ureport:reportGroup:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(reportGroupService.selectReportGroupById(id));
    }

    /**
     * 新增报分组
     */
    @ApiOperation(value = "新增报分组", notes = "新增报分组")
    @PreAuthorize("@ss.hasPermi('ureport:reportGroup:add')")
    @Log(title = "报分组", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReportGroup reportGroup)
    {
        return toAjax(reportGroupService.insertReportGroup(reportGroup));
    }

    /**
     * 修改报分组
     */
    @ApiOperation(value = "修改报分组", notes = "修改报分组")
    @PreAuthorize("@ss.hasPermi('ureport:reportGroup:edit')")
    @Log(title = "报分组", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReportGroup reportGroup)
    {
        return toAjax(reportGroupService.updateReportGroup(reportGroup));
    }

    /**
     * 删除报分组
     */
    @ApiOperation(value = "删除报分组", notes = "删除报分组")
    @PreAuthorize("@ss.hasPermi('ureport:reportGroup:remove')")
    @Log(title = "报分组", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(reportGroupService.deleteReportGroupByIds(ids));
    }
}
